﻿<%@ Page Title="Calendário de Aulas" Language="C#" MasterPageFile="~/Site.Master"
    AutoEventWireup="true" CodeBehind="CadastroCalendarioAula.aspx.cs" Inherits="AcadPosApp.Cadastros.CadastroCalendarioAula" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style3
        {
            width: 52px;
        }
        .style4
        {
            width: 157px;
        }
        .style5
        {
            width: 158px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel ID="pnlConsulta" runat="server" GroupingText="Consulta do Calendário de Aulas"
        Style="margin-bottom: 0px">
        <table>
            <tr>
                <td class="style15" colspan="3">
                    Estado &nbsp;
                </td>
            </tr>
            <tr>
                <td class="style15" colspan="3">
                    <asp:DropDownList ID="ddlEstadoPesquisa" runat="server" OnSelectedIndexChanged="ddlEstadoPesquisa_SelectedIndexChanged"
                        Width="150px" AutoPostBack="True">
                    </asp:DropDownList>
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td class="style15" colspan="3">
                    Polo &nbsp;
                </td>
            </tr>
            <tr>
                <td class="style15" colspan="3">
                    <asp:DropDownList ID="ddlPoloPesquisa" runat="server" Enabled="False" Width="300px"
                        AutoPostBack="True">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style4">
                    <asp:Label ID="Label1" runat="server" Text="Data Início"></asp:Label>
                    <br />
                    <asp:TextBox ID="TxtDataIniPesq" runat="server" required Width="145px"></asp:TextBox>
                    <asp:CalendarExtender ID="TxtDataIniPesq_CalendarExtender" runat="server" Enabled="True"
                        TargetControlID="TxtDataIniPesq">
                    </asp:CalendarExtender>
                </td>
                <td class="style5">
                    <asp:Label ID="Label2" runat="server" Text="Data Fim"></asp:Label>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:TextBox ID="TxtDataFimPesq" runat="server" required Width="145px"></asp:TextBox>
                    <asp:CalendarExtender ID="TxtDataFimPesq_CalendarExtender" runat="server" Enabled="True"
                        TargetControlID="TxtDataFimPesq">
                    </asp:CalendarExtender>
                </td>
                <td class="style15">
                    <br />
                    <asp:Button ID="btnConsultar" runat="server" Text="Consultar" OnClick="btnConsultar_Click" />
                </td>
            </tr>
        </table>
        <br />
        <asp:GridView ID="gvwCalendario" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CssClass="mGrid" EmptyDataText="Dados não localizados..." GridLines="Vertical"
            Width="45%" DataKeyNames="ID_CALENDARIO" OnRowCreated="gvwCalendario_RowCreated"
            OnRowDataBound="gvwCalendario_RowDataBound" OnRowCommand="gvwCalendario_RowCommand"
            OnSelectedIndexChanged="gvwCalendario_SelectedIndexChanged" 
            OnPageIndexChanging="gvwCalendario_PageIndexChanging">
            <AlternatingRowStyle BackColor="#D3D3D3" />
            <Columns>
                <asp:CommandField ButtonType="Image" SelectImageUrl="~/Imagens/select.png" ShowSelectButton="True">
                    <ItemStyle Width="1%" />
                </asp:CommandField>
                <asp:TemplateField HeaderText="Editar" ShowHeader="False">
                    <ItemTemplate>
                        <abbr>
                            <asp:ImageButton ID="ImgAlterar" runat="server" CausesValidation="false" CommandName="Alterar"
                                formnovalidate="formnovalidate" ImageUrl="~/Imagens/edit.png" Text="Alterar"
                                Width="20px" />
                        </abbr>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Excluir" ShowHeader="False">
                    <ItemTemplate>
                        <abbr title="Excluir">
                            <asp:ImageButton ID="ImgExcluir" runat="server" CausesValidation="false" CommandName="Excluir"
                                formnovalidate="formnovalidate" ImageUrl="~/Imagens/delete.png" OnClientClick="return ShowConfirm('Tem certeza que deseja excluir?', this.ID);"
                                Text="Excluir" Width="20px" />
                        </abbr>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:BoundField DataField="POLO" HeaderText="Polo">
                    <HeaderStyle HorizontalAlign="Left" Width="1%" />
                    <ItemStyle HorizontalAlign="Left" Width="90%" />
                </asp:BoundField>
                <asp:BoundField DataField="DATA_AULA" HeaderText="Data Aula">
                    <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    <ItemStyle HorizontalAlign="Left" Width="10%" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Status">
                    <ItemTemplate>
                        <asp:Image ID="imgStatus" runat="server" Height="25px" Width="25px" />
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:BoundField DataField="SITUACAO" HeaderText="Situação">
                    <ItemStyle HorizontalAlign="Center" Width="5%" />
                </asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#808080" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#383838" />
        </asp:GridView>
        <br />
        &nbsp;&nbsp;
        <asp:Button ID="btnInserir" formnovalidate="false" runat="server" Text="Inserir"
            OnClick="btnInserir_Click" Width="100px" /><br /><br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlHorarioData" runat="server" GroupingText="Horários da Data" Visible="False">
        <asp:GridView ID="gvwHoraDatas" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CssClass="mGrid" EmptyDataText="Dados não localizados..." GridLines="Vertical"
            DataKeyNames="ID_CALENDARIO_HORARIO" 
            OnRowCreated="gvwHoraDatas_RowCreated" OnRowDataBound="gvwHoraDatas_RowDataBound"
            Width="45%" OnPageIndexChanging="gvwHoraDatas_PageIndexChanging" 
            OnRowCommand="gvwHoraDatas_RowCommand">
            <AlternatingRowStyle BackColor="#D3D3D3" />
            <Columns>
                <asp:TemplateField HeaderText="Excluir" ShowHeader="False">
                    <ItemTemplate>
                        <abbr title="Excluir">
                            <asp:ImageButton ID="ImgExcluir" runat="server" CausesValidation="false" CommandName="Excluir"
                                formnovalidate="formnovalidate" ImageUrl="~/Imagens/delete.png" OnClientClick="return ShowConfirm('Tem certeza que deseja excluir?', this.ID);"
                                Text="Excluir" Width="20px" />
                        </abbr>
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:BoundField DataField="TURNO" HeaderText="Turno">
                    <HeaderStyle HorizontalAlign="Left" Width="1%" />
                    <ItemStyle HorizontalAlign="Left" Width="90%" />
                </asp:BoundField>
                <asp:BoundField DataField="HORA_INICIO" HeaderText="Hora Início">
                    <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    <ItemStyle HorizontalAlign="Left" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="HORA_FIM" HeaderText="Hora Fim"></asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#808080" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#383838" />
        </asp:GridView>
        <br />
        <asp:Button ID="btnInserirHoraData" runat="server" OnClick="btnInserirHoraData_Click"
            Text="Inserir" Width="100px" /><br /><br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlCadastroCalendario" runat="server" GroupingText="Cadastro do Calendário de Aulas"
        Visible="False">
        <table class="style1">
            <tr>
                <td colspan="2">
                    <asp:Label ID="Label3" runat="server" Text="Estado"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlEstadoCad" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlEstadoCad_SelectedIndexChanged"
                        Width="150px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Label ID="Label4" runat="server" Text="Polo"></asp:Label>
                    <br />
                    <asp:DropDownList ID="ddlPoloCad" runat="server" Enabled="False" Width="300px">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Label ID="Label5" runat="server" Text="Data"></asp:Label>
                    <br />
                    <asp:TextBox ID="TxtDataCad" required runat="server" Width="150px"></asp:TextBox>
                    <asp:CalendarExtender ID="TxtDataCad_CalendarExtender" runat="server" Enabled="True"
                        TargetControlID="TxtDataCad">
                    </asp:CalendarExtender>
                </td>
                <td>
                    <br />
                </td>
            </tr>
            <tr>
                <td class="style3">
                    <asp:Label ID="Label6" runat="server" Text="Situação"></asp:Label>
                    <asp:DropDownList ID="ddlSituacao" runat="server" Width="150px">
                        <asp:ListItem Value="A">Ativo</asp:ListItem>
                        <asp:ListItem Value="I">Inativo</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
        <br />
        <asp:Button ID="btnConfirmar" runat="server" OnClick="btnConfirmar_Click" 
            Text="Confirmar" Width="100px" />
        &nbsp;<asp:Button ID="btnCancelar" formnovalidate runat="server" OnClick="btnCancelar_Click"
            Text="Cancelar" Width="100px" /><br /><br />
    </asp:Panel>
    <br />
    <asp:Panel ID="pnlCadastroHorario" runat="server" GroupingText="Cadastro de Horários das Datas"
        Visible="False">
        <asp:GridView ID="gvwHorarios" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CssClass="mGrid" EmptyDataText="Dados não localizados..." GridLines="Vertical"
            DataKeyNames="ID_HORARIO" Width="50%" OnPageIndexChanging="gvwHorarios_PageIndexChanging">
            <AlternatingRowStyle BackColor="#D3D3D3" />
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <HeaderTemplate>
                        <asp:CheckBox ID="CheckAll" runat="server" onclick="javascript:SelecionaTodosChecks(this)"
                            Width="20px" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
                    </ItemTemplate>
                    <HeaderStyle HorizontalAlign="Center" Width="1%" />
                    <ItemStyle HorizontalAlign="Center" Width="1%" />
                </asp:TemplateField>
                <asp:BoundField DataField="TURNO" HeaderText="Turno">
                    <HeaderStyle HorizontalAlign="Left" Width="1%" />
                    <ItemStyle HorizontalAlign="Left" Width="90%" />
                </asp:BoundField>
                <asp:BoundField DataField="HORA_INICIO" HeaderText="Hora Início">
                    <HeaderStyle HorizontalAlign="Center" Width="10%" />
                    <ItemStyle HorizontalAlign="Left" Width="10%" />
                </asp:BoundField>
                <asp:BoundField DataField="HORA_FIM" HeaderText="Hora Fim"></asp:BoundField>
            </Columns>
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <PagerStyle CssClass="pagination" ForeColor="Black" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#1E90FF" Font-Bold="True" ForeColor="White" />
            <SortedAscendingCellStyle BackColor="#F1F1F1" />
            <SortedAscendingHeaderStyle BackColor="#808080" />
            <SortedDescendingCellStyle BackColor="#CAC9C9" />
            <SortedDescendingHeaderStyle BackColor="#383838" />
        </asp:GridView>
        <br />
        <asp:Button ID="btnConfirmarHorario" runat="server" OnClick="btnConfirmarHorario_Click"
            Text="Confirmar" Width="100px" />
        &nbsp;<asp:Button ID="btnCancelarHorario" runat="server" OnClick="btnCancelarHorario_Click"
            Text="Cancelar" Width="100px" /><br /><br />
    </asp:Panel>
    <script language="javascript" type="text/javascript">
        function SelecionaTodosChecks(spanChk) {

            var oItem = spanChk.children;

            var theBox = (spanChk.type == "checkbox") ? spanChk : spanChk.children.item[0];

            xState = theBox.checked;

            elm = theBox.form.elements;

            for (i = 0; i < elm.length; i++)

                if (elm[i].type == "checkbox" && elm[i].id != theBox.id) {
                    if (elm[i].checked != xState)

                        elm[i].click();
                }
        }
    </script>
</asp:Content>
